<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
        姓名：<input type="text" name="name" class="name">
      <button>
          提交
      </button>
</body>
<script src="jquery-3.3.1.min.js"></script>
<script>
    $(document).on('click','button',function(){
        const name = $(".name").val();
        $.ajax({
            type: 'post',
            url: '/user',
            data: {
                'name': name,
            },
            success: function (data) { 
                console.log(data); //{code:1,msg:'post请求'}
                alert(data.msg)
            },
            error: function () {
                alert('请求错误')
            }
        })
    })
</script>
</html>